package com.zoranjoka.chordis.dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Session;

import com.zoranjoka.chordis.entities.Artist;
import com.zoranjoka.chordis.entities.ArtistBean;

public class ArtistDAOImpl implements ArtistDAO {

	private final Session session;

	public ArtistDAOImpl (Session s) {
		this.session = s;
	}
	
	public void save(Artist a) {
		session.save(a);

	}

	public void delete(Artist a) {
		session.delete(a);

	}

	public Artist findById(Serializable id) {
		return (Artist) session.get(ArtistBean.class,id);
	}

	public List<Artist> getAll() {
		return session.createCriteria(ArtistBean.class).list();
	}

	@Override
	public void update(Artist a) {
		session.saveOrUpdate(a);
	}

}
